package cn.acheng1314.im.socket.handler;

import cn.acheng1314.im.common.handler.ServerAbstractHeartbeatHandler;
import cn.acheng1314.im.socket.model.PingMessage;
import cn.acheng1314.im.socket.model.PongMessage;
import io.netty.channel.ChannelHandlerContext;

public class SocketHeartbeatHandler extends ServerAbstractHeartbeatHandler {
    @Override
    protected void writeHeartbeat(ChannelHandlerContext ctx) {
        PingMessage pingMessage = PingMessage.getInstance();
        ctx.writeAndFlush(pingMessage);
    }

    @Override
    protected boolean isHeartbeat(ChannelHandlerContext ctx, Object msg) {
        return msg instanceof PongMessage;
    }

}
